workspace "FairyIsland"
    architecture "x64"
    configurations
    {
        "Debug",
        "Release",
        "Dist"
    }

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
-- Include directorise relative to root folder
IncludeDir = {}
IncludeDir["GLFW"] = "FairyIsland/vendor/GLFW/include"
IncludeDir["Glad"] = "FairyIsland/vendor/Glad/include"
IncludeDir["ImGui"] = "FairyIsland/vendor/imgui"

include "FairyIsland/vendor/GLFW/"
include "FairyIsland/vendor/Glad/"
include "FairyIsland/vendor/imgui/" 

project "FairyIsland"
    location "FairyIsland"
    kind "SharedLib"
    language "C++"

    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
    
    pchheader "hzpch.h"
    pchsource "FairyIsland/src/hzpch.cpp"

    files
    {
        "%{prj.name}/src/**.h",
        "%{prj.name}/src/**.cpp"
    }

    includedirs
    {
        "%{prj.name}/vendor/spdlog/include",
        "%{prj.name}/src",
        "%{IncludeDir.GLFW}",
        "%{IncludeDir.Glad}",
        "%{IncludeDir.ImGui}"
    }
    libdirs
    {
        "%{prj.name}/vendor/GLFW/bin/" .. outputdir .. "/GLFW"
    }
    links
    {
        "GLFW",
        "Glad",
        "ImGui",
        "opengl32.lib"
    }

    filter "system:Windows"
        cppdialect "C++17"
        staticruntime "On"
        systemversion "latest"

        defines
        {
            "GLFW_INCLUDE_NONE",
            "_CRT_SECURE_NO_WARNINGS",
            "FI_PLATFORM_WINDOWS",
            "FI_BUILD_DLL"
        }

        -- ignoredefaultlibraries
        -- {
        --     "libucrtd.lib",
        --     "libcmtd.lib"
        -- }

        postbuildcommands
        {
            ("{COPY} ../bin/" ..outputdir.. "/%{prj.name}/%{prj.name}.dll  ../bin/" .. outputdir .. "/Sandbox")
        }

        
    filter "configurations:Debug"
        defines "FI_DEBUG"
        buildoptions "/MDd"
        symbols "On"

    filter "configurations:Release"
        defines "FI_Release"
        buildoptions "/MD"
        optimize "On"

    filter "configurations:Dist"
        defines "FI_Dist"
        buildoptions "/MD"
        optimize "On"


project "Sandbox"
    location "Sandbox"
    kind "ConsoleApp"
    language "C++"

    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

    files
    {
        "%{prj.name}/src/**.h",
        "%{prj.name}/src/**.cpp",
    }

    includedirs
    {
        "FairyIsland/vendor/spdlog/include",
        "FairyIsland/src"
    }

    links
    {
        "FairyIsland"
    }

    filter "system:Windows"
        cppdialect "C++17"
        staticruntime "On"
        systemversion "latest"

        defines
        {
            "FI_PLATFORM_WINDOWS"
        }
    
    filter "configurations:Debug"
        defines "FI_DEBUG"
        buildoptions "/MDd"
        symbols "On"

    filter "configurations:Release"
        defines "FI_Release"
        buildoptions "/MD"
        optimize "On"

    filter "configurations:Dist"
        defines "FI_Dist"
        buildoptions "/MD"
        optimize "On"